
    <!DOCTYPE html>
    <html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>

    <body>
       
        <script>
        
        
        
        
        function util(arr, newarr = [], id = 1, pid = 0) {//扁平化
            if (!arr || !Array.isArray(arr) || arr.length == 0) return arr;
            function toView(str) {
                if (!str) return ""
                let index = str.split("/").indexOf("views");
                let newstr = str.split("/").slice(index + 1,).join("/")
                return newstr.replace(/(.vue)?[\'\"]\)$/g, "")
            }
            let newobj = {}
            for (let obj of arr) {
                id = newarr.length + 1
                newobj = {
                    id,
                    pid,
                    ...obj,
                    component: toView(String(obj.component)),
                }
                delete newobj.children
                newarr.push(newobj);
                if (obj.children && obj.children.length > 0) {
                    util(obj.children, newarr, id, id)
                }
            }
            return newarr
        }
        
        
        function tree(arr) { //反扁平化
            if (!arr || !Array.isArray(arr) || arr.length == 0) return arr;
            arr = arr.map(v => {
                if (v.component && (v.component === "HomeView" || v.component === "IndexView")) {
                    v.component = v.component
                } else {
                    v.component = () => import('@/views/' + v.component + '.vue')
                }
                return v
            })
            let newarr = arr.filter(item => {
                item.children = arr.filter(v => {
                    return item.id == v.pid
                })
                return !item.pid
            })
        
            return newarr
        
        }
        
        
        function path(arr, newarr = [], pathstr = " ") {
            for (let item of arr) {
                if (item.children && item.children.length > 0) {
                    path(item.children, newarr, pathstr + item.path)
                } else {
                    newarr.push({
                        path: (pathstr + '/' + item.path).split('/').slice(2).join('/'),
                        title: item.meta.menuTitle
                    })
        
                }
            }
            return newarr
        }
        console.log(path(obj))
        
        
        
        const addRoute = [
            {
                path: '/',
                name: 'home',
                meta: {
                    menu: false,
                    role: ['manager', 'storehouse', 'sales'],
                    title: "Saas平台"
                },
                component: () => import('@/views/HomeView.vue')
            },
            {
                path: "/purchase",//一级菜单
                name: "purchase",
                component: "HomeView",
                meta: {
                    menu: true,//渲染为菜单
                    menuTitle: "采购",
                    icon: "el-icon-menu",
                    // role: ['manager总经理', 'sales销售', 'storehouse仓库管理员']
                    role: ['manager', 'storehouse', 'sales']
                },
                children: [//二级菜单
                    {
                        path: "/purchase",
                        name: "purchase-1",
                        component: () => import('../views/IndexView.vue'),
                        meta: {
                            menu: true,
                            menuTitle: "采购",
                            icon: "el-icon-menu",
                            role: ['manager', 'storehouse', 'sales']
                        },
                        children: [//菜单选项
                            {
                                path: "",
                                name: 'pro',
                                component: () => import('../views/procurement/ProMent.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "采购管理",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                            {
                                path: "apply",
                                name: 'apply',
                                component: () => import('../views/procurement/ProApply.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "采购申请",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'sales']
                                }
                            }, {//编辑，添加同一页面
                                path: "addPurchase",
                                name: "addPurchase",
                                component: () => import('@/views/procurement/AddPurchase.vue'),
                                meta: {
                                    menu: false,
                                    menuTitle: "采购申请",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse', 'sales']
                                }
                            },
                            {
                                path: "preview",
                                name: "preview",
                                component: () => import('@/views/procurement/PreView.vue'),
                                meta: {
                                    menu: false,
                                    menuTitle: "采购预览",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            }
                        ]
        
                    },
                ]
            },
            //刘馨蔓
            {
                path: "/inventory",
                name: "inventory",
                component: "HomeView",
                meta: {
                    menu: true,//渲染为菜单
                    menuTitle: "库存",
                    icon: "el-icon-menu",
                    role: ['manager', 'storehouse']
                },
                children: [
                    {
                        path: "/outmangement",//二级菜单
                        name: "outmangement",
                        component: () => import('../views/IndexView.vue'),
                        meta: {
                            menu: true,
                            menuTitle: "出库管理",
                            icon: "el-icon-menu",
                            role: ['manager', 'storehouse']
                        },
                        children: [
                            {
                                path: "out",//
                                name: "outmangement",
                                component: () => import('../views/inventory/OutManagement.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "出库管理",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                            {
                                path: "addoutlist",//
                                name: "add",
                                component: () => import('../views/inventory/AddoutList.vue'),
                                meta: {
                                    menu: false,
                                    menuTitle: "添加出库单",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
        
                            {
                                path: "inventoryviewout",//
                                name: "view",
                                component: () => import('../views/inventory/ViewDetailsOut.vue'),
                                meta: {
                                    menu: false,
                                    menuTitle: "出库预览",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
        
        
                        ]
                    },
                    {
                        path: "/inmangement",//二级菜单
                        name: "inmangement",
                        component: () => import('../views/IndexView.vue'),
                        meta: {
                            menu: true,
                            menuTitle: "入库管理",
                            icon: "el-icon-menu",
                            role: ['manager', 'storehouse']
                        },
                        children: [
                            {
                                path: "in",
                                name: "inmangement",
                                component: () => import('../views/inventory/InManagement.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "入库管理",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                            {
                                path: "inventoryviewin",//
                                name: "view",
                                component: () => import('../views/inventory/ViewDetailsIn.vue'),
                                meta: {
                                    menu: false,
                                    menuTitle: "入库预览",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                            {
                                path: "addinlist",//
                                name: "add",
                                component: () => import('../views/inventory/AddinList.vue'),
                                meta: {
                                    menu: false,
                                    menuTitle: "添加入库",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                        ]
                    },
                ]
        
            },
            //邹杰
            {
                path: "/xiaoshou",//一级菜单
                name: "xiaoshou",
                component: "HomeView",
                meta: {
                    menu: true,//渲染为菜单
                    menuTitle: "销售",
                    icon: "el-icon-menu",
                    role: ['manager', 'sales']
                },
                children: [//二级菜单
                    {
                        path: "/dingdan",
                        name: "/dingdan",
                        component: () => import('../views/IndexView.vue'),
                        meta: {
                            menu: true,
                            menuTitle: "订单管理",
                            icon: "el-icon-menu",
                            role: ['manager', 'sales']
                        },
                        children: [//菜单选项
                            {
                                path: "dingdan-list",
                                name: 'dingdan-list',
                                component: () => import('../views/zone/XiaoShouList.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "订单列表",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'sales']
                                }
                            },
                            {
                                path: "add-list",
                                name: 'add-list',
                                component: () => import('../views/zone/DinDanList.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "添加订单",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'sales']
                                }
                            }
                        ]
        
                    },
                ]
            },
            //董彦宇
            {
                path: "/Xingwei",//一级菜单
                name: "Xingwei",
                component: "HomeView",
                meta: {
                    menu: true,//渲染为菜单
                    menuTitle: "行为",
                    icon: "el-icon-menu",
                    role: ['manager', 'storehouse', 'sales']
                },
                children: [
                    {
                        path: "/Xingwei-1",//二级菜单
                        name: "Xingwei-1",
                        component: () => import('../views/IndexView.vue'),
                        meta: {
                            menu: true,
                            menuTitle: "路线管理",
                            icon: "el-icon-menu",
                            role: ['manager', 'sales']
                        },
                        children: [
                            {
                                path: "Xingwei-1-1",//菜单选项
                                name: 'Xingwei-1-1',
                                component: () => import('../views/xingwei/luxian/XingWei.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "路线管理",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'sales']
                                }
                            },
                            {
                                path: "Xingwei-1-2",
                                name: 'Xingwei-1-2',
                                component: () => import('../views/xingwei/luxian/DindanList.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "添加路线",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'sales']
                                }
                            },
                            {
                                path: "purchase-1-3",
                                name: 'purchase-1-3',
                                component: () => import('../views/xingwei/luxian/BaiJie.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "拜访结果查询",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'sales']
                                }
                            },
                            {
                                path: "Xingwei-1-4",
                                name: 'Xingwei-1-4',
                                component: () => import('../views/xingwei/luxian/BaiTong.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "拜访统计",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'sales']
                                }
                            },
                            {
                                path: "Xingwei-1-5",
                                name: 'Xingwei-1-5',
                                component: () => import('../views/xingwei/luxian/ShangChuan.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "上传信息系统",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'sales']
                                }
                            },
        
                        ]
                    },
                    {
                        path: "/Xingwei-2",//二级菜单
                        name: "Xingwei-2",
                        component: () => import('../views/IndexView.vue'),
                        meta: {
                            menu: true,
                            menuTitle: "销售管理",
                            icon: "el-icon-menu",
                            role: ['manager', 'storehouse']
                        },
                        children: [
                            {
                                path: "Xingwei-1-3",
                                name: 'Xingwei-1-3',
                                component: () => import('../views/xingwei/xiaoshou/RenXiao.vue'),
        
                                meta: {
                                    menu: true,
                                    menuTitle: "人员销售动态",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                            {
                                path: "XiaoShou-1-4",
                                name: 'Xiaoshou-1-4',
                                component: () => import('../views/xingwei/xiaoshou/ShangXiao.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "商品销售动态",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                            {
                                path: "XiaoShou-1-5",
                                name: 'Xiaoshou-1-5',
                                component: () => import('../views/xingwei/xiaoshou/MenXiao.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "门店销售动态",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                        ]
                    }
                ]
            },
            {
                path: "/system",//一级菜单
                name: "system",
                component: "HomeView",
                meta: {
                    menu: true,//渲染为菜单
                    menuTitle: "系统",
                    icon: "el-icon-menu",
                    role: ['manager', 'storehouse']
                },
                children: [//二级菜单
                    //徐彬鑫
                    {
                        path: "/xitong-1",//二级菜单
                        name: "xitong-1",
                        component: () => import('../views/IndexView.vue'),
                        meta: {
                            menu: true,
                            menuTitle: "基本资料",
                            icon: "el-icon-menu",
                            role: ['manager', 'storehouse']
                        },
                        children: [
                            {
                                path: 'xinxi',
                                name: 'xinxi',
                                component: () => import('../views/system/GongMess.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: '公司信息',
                                    icon: 'el-icon-menu',
                                    role: ['manager']
                                }
                            },
                            {
                                path: "bumen",
                                name: 'bumen',
                                component: () => import('../views/system/BumenMent.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "部门管理",
                                    icon: "el-icon-menu",
                                    role: ['manager']
                                }
                            },
                            {
                                path: "purchase-1-3",
                                name: 'purchase-1-3',
                                component: () => import('@/views/system/basic/PositionView'),
                                meta: {
                                    menu: true,
                                    menuTitle: "职位管理",
                                    icon: "el-icon-menu",
                                    role: ['manager']
                                }
                            },
                            {
                                path: "permission",
                                name: 'permission',
                                component: () => import('../views/system/basic/PermissionsView'),
                                meta: {
                                    menu: false,
                                    menuTitle: "权限设置",
                                    icon: "el-icon-menu",
                                    role: ['manager']
                                }
                            },
                            {
                                path: "yuangong",
                                name: 'yuangong',
                                component: () => import('../views/system/YuanMess.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "员工管理",
                                    icon: "el-icon-menu",
                                    role: ['manager']
                                }
                            },
                            //邹杰
                            {
                                path: "store",//菜单选项
                                name: 'store',
                                component: () => import('../views/system/ziliao/CangKu.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "仓库管理",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                            {
                                path: "unit",
                                name: 'unit',
                                component: () => import('../views/system/ziliao/JiLiang.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "计量单位",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                            {
                                path: "operation",
                                name: 'operation',
                                component: () => import('../views/system/ziliao/RiZhi.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "操作日志",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                            {
                                path: "addyuan",
                                name: "addyuan",
                                component: () => import('../views/system/AddYuan.vue'),
                                meta: {
                                    menu: false,
                                    menuTitle: "添加员工",
                                    role: ['manager']
                                }
                            },
                        ]
                    },
                    //陈芬
                    {
                        path: "/goods",//二级菜单
                        name: "goods",
                        component: () => import('../views/IndexView.vue'),
                        meta: {
                            menu: true,
                            menuTitle: "商品管理",
                            icon: "el-icon-menu",
                            role: ['manager', 'storehouse']
                        },
                        children: [
                            {
                                path: "brand",//菜单选项
                                name: 'brand',
                                component: () => import('../views/system/commodity-management/BrandView.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "品牌管理",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                            {
                                path: "classifity",
                                name: 'classifity',
                                component: () => import('../views/system/commodity-management/ClassifityView.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "商品分类-一级",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                            {
                                path: "information",
                                name: 'Information',
                                component: () => import('../views/system/commodity-management/InformationView.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "商品信息维护",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                            {
                                path: "top",
                                name: 'top',
                                component: () => import('../views/system/commodity-management/TopView.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "商品置顶",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                            {
                                path: "addGoods",
                                name: 'addGoods',
                                component: () => import('../views/system/commodity-management/AddClassify.vue'),
                                meta: {
                                    menu: false,
                                    menuTitle: "添加商品",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                            {
                                path: 'addBrand',
                                name: 'addBrand',
                                component: () => import('../views/system/commodity-management/BrandNew.vue'),
                                meta: {
                                    menu: false,
                                    menuTitle: "添加新品牌",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                            {
                                path: 'addClassify',
                                name: 'addClassify',
                                component: () => import('../views/system/commodity-management/AddClassify.vue'),
                                meta: {
                                    menu: false,
                                    menuTitle: "添加分类",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                            {
                                path: 'lookSubordinate',
                                name: 'lookSubordinate',
                                component: () => import('../views/system/commodity-management/LookSubordinate.vue'),
                                meta: {
                                    menu: false,
                                    menuTitle: "商品分类-二级",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            },
                            {
                                path: 'informationAdd',
                                name: 'informationAdd',
                                component: () => import('@/views/system/commodity-management/GoodsView.vue'),
                                meta: {
                                    menu: false,
                                    menuTitle: "商品信息添加",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                }
                            }
                        ],
                    },
                    // 张浩
                    {
                        path: "/system-2", //二级菜单
                        name: "system-2",
                        component: () => import('../views/IndexView.vue'),
                        meta: {
                            menu: true,
                            menuTitle: "客户管理",
                            icon: "el-icon-menu",
                            role: ['manager', 'sales']
                        },
                        children: [
                            {
                                path: "system-2-1", //菜单选项
                                name: 'system-2-1',
                                component: () => import('../views/system/MerchantManagement/CustomerManagement.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "客户信息",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'sales']
                                },
                            },
                            {
                                path: "system-2-2",
                                name: 'system-2-2',
                                component: () => import('../views/system/MerchantManagement/CustomerType.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "客户类型",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'sales']
                                }
                            },
                            {
                                path: "system-2-3",
                                name: 'system-2-3',
        
                                meta: {
                                    menu: true,
                                    menuTitle: "客户区域",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'sales']
                                }
                            },
                            {
                                path: "system-2-4",
                                name: 'system-2-4',
                                component: () => import('../views/system/MerchantManagement/SuppLiers.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "供货厂商",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'sales']
                                }
                            },
                            {
                                path: "system-2-1-1",
                                name: "system-2-1-1",
                                component: () => import('../views/system/MerchantManagement/AddCustomer.vue'),
                                meta: {
                                    menu: false,
                                    menuTitle: "添加客户",
                                    role: ['manager', 'sales']
                                },
                            },
                            {
                                path: "system-2-4-1",
                                name: "system-2-4-1",
                                component: () => import('../views/system/MerchantManagement/AddVendors.vue'),
                                meta: {
                                    menu: false,
                                    menuTitle: "添加供货厂商",
                                    role: ['manager', 'sales']
                                },
                            },
                        ]
                    },
                    // 王冰
                    {
                        path: "/system",
                        name: "system-1",
                        component: () => import('../views/IndexView.vue'),
                        meta: {
                            menu: true,
                            menuTitle: "价格体系",
                            icon: "el-icon-menu",
                            role: ['manager', 'storehouse']
                        },
                        children: [//menu:true 菜单选项
                            {
                                path: "system-1-1",
                                name: 'system-1-1',
                                component: () => import('../views/system/price/PriceView.vue'),
                                meta: {
                                    menu: true,
                                    menuTitle: "价格体系设置",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                },
                            },
                            {
                                path: "cust",
                                name: 'cust',
                                meta: {
                                    menu: false,
                                    menuTitle: "客户类型和价格体系",
                                    icon: "el-icon-menu",
                                    role: ['manager', 'storehouse']
                                },
                                component: () => import('../views/system/price/CustomerView.vue'),
                            }
                        ]
                    },
                ]
            },
        ]
        
        
        
        
        function filterRouter(initRoute, storehouse) {
            function loop(initRoute, storehouse) {
                return initRoute.filter(v => {
                    if (v.meta.role.includes(storehouse)) {
                        if (v.children && v.children.length > 0) {
                            v.children = loop(v.children, storehouse)
                        }
                        return true
                    }
                })
            }
            return loop(initRoute, storehouse)
        
        }
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        </script>
    </body>

    </html>
